package com.lovi.mysql_;

import com.lovi.dao.ActorDao;
import com.lovi.domain.Actor;
import org.junit.jupiter.api.Test;

import java.util.List;

public class TestActorDao {
    private ActorDao actorDao = new ActorDao();

    /**
     * dml
     */
    @Test
    public void testDml() {
        actorDao.update("insert into actor (name) values (?)", "lovi");
    }

    /**
     * 查询list
     */
    @Test
    public void testQueryList() {
        List<Actor> list = actorDao.list(Actor.class, "select * from actor where id > ?", 1);
        list.forEach(System.out::println);
    }
    /**
     * 查询单个
     */
    @Test
    public void testQuerySingle() {
        Actor actor = actorDao.getOneById(Actor.class, "select * from actor where id = ?", 1);
        System.out.println(actor);
    }
    /**
     * 查询单个actor的单个列
     */
    @Test
    public void testQuerySingleColumn() {
        String name = actorDao.getOneFiledById(String.class, "select name from actor where id = ?", 1);
        System.out.println(name);
    }

}
